package com.retail.proxy.controller;

import com.retail.core.common.AbstractCommonController;
import com.retail.core.entity.ParamReq;

import com.retail.core.entity.result.PageResult;
import com.retail.core.entity.result.Result;
import com.retail.global.security.LoginUserUtil;
import com.retail.global.annon.TraceLog;
import com.retail.proxy.entity.request.ProxyUpgradeConfigRequest;
import com.retail.proxy.entity.vo.ProxyUpgradeConfigVo;
import com.retail.proxy.service.ProxyUpgradeConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 晋升配置 API
* @author Administrator
*/
@Api(tags = "晋升配置 API")
@RestController
@RequestMapping("/proxyUpgradeConfig")
public class ProxyUpgradeConfigController extends AbstractCommonController<ProxyUpgradeConfigService, ProxyUpgradeConfigRequest, ProxyUpgradeConfigVo>{

    @Autowired
    private ProxyUpgradeConfigService proxyUpgradeConfigService;

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(proxyUpgradeConfigService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存晋升配置")
    public Result<Integer> save(@RequestBody ProxyUpgradeConfigRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(proxyUpgradeConfigService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新晋升配置")
    public Result<Integer> update(@RequestBody ProxyUpgradeConfigRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(proxyUpgradeConfigService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("晋升配置-查询")
    public Result<List<ProxyUpgradeConfigVo>>listPage(@RequestBody ParamReq req) {
        return super.listPage(proxyUpgradeConfigService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("晋升配置-统计")
    public Result<Integer> countPage(@RequestBody ParamReq req) {
        return super.countPage(proxyUpgradeConfigService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("晋升配置-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<ProxyUpgradeConfigRequest> req) {
        return super.page(proxyUpgradeConfigService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除晋升配置")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(proxyUpgradeConfigService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除晋升配置")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(List<Long> ids) {
        return super.batchDelete(proxyUpgradeConfigService, ids);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
